/*include:js\mouseMenu*/
/*include:js\autoHeight*/
/*include:js\floatCenter*/
/*include:js\textHeight*/
/*include:js\cookie*/
/*include:js\mathJax\load*/
/*include:loadAjax*/
/*include:onImage*/
/*include:js\poll*/
if(navigator.appVersion&&navigator.appVersion.indexOf('MicroMessenger')+1)	fastCSharp.AppendHead('meta',{name:'viewport',content:'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;'});
var Header=	{
Logout:function()
	{
	LoadAjax.Post(fastCSharp.ThisFunction(this,this.OnLogout),'pub.Logout');
	},
OnLogout:function()
	{
	location='/default.html';
	},
Load:function()
	{
	this.ReadNoticeIds={};
	this.NoticeMenu=fastCSharp.GetMouseMenu('headerNotice');
	var SkinValue=fastCSharp.PageView.SkinValue.SkinValue;
	if(SkinValue.currentUser)
		{
//		fastCSharp.OnModule(['htmlEditor']);
		fastCSharp.Poll.ReturnName='value';
		fastCSharp.Poll.Path='/enterprise/poll.html';
		fastCSharp.Poll.Query.NoticeIds=[];
		fastCSharp.Poll.Query.Message=SkinValue.currentUser.MessageNewUserCount;
		if(!this.IsPoll)
			{
			fastCSharp.Poll.OnMessage.Add(fastCSharp.ThisFunction(this,this.OnPoll));
			this.IsPoll=1;
			}
		fastCSharp.Poll.Start({UserId:SkinValue.currentUser.Id,Verify:SkinValue.pollVerify});
		}
	},
OnPoll:function(Value)
	{
	var SkinValue=fastCSharp.PageView.SkinValue,Poll=SkinValue.currentUser.EnterprisePoll,OldNotices=Poll.SkinValue.Notices,Notices=Value.Notices||[];
	Poll.SkinValue.Notices=[];
	for(var Index=Notices.length;Index;)
		{
		if(!this.ReadNoticeIds[Notices[--Index].Id])	Poll.SkinValue.Notices.push(Notices[Index]);
		}
	OldNotices=OldNotices.ToHash(function(Value){return Value.Id;});
	for(var NoticeIds=Value.NoticeIds||[],Index=NoticeIds.length;Index;)
		{
		var NoticeId=-NoticeIds[--Index];
		if(OldNotices[NoticeId]&&!this.ReadNoticeIds[NoticeId])	Poll.SkinValue.Notices.push(OldNotices[NoticeId]);
		}
	Poll.Notice.Set(fastCSharp.Poll.Query.Notice=Value.NoticeCount);
	if(Value.Radio!=Poll.SkinValue.Radio)	Poll.Radio.Set(fastCSharp.Poll.Query.Radio=Value.Radio);
	if(Value.MultipleChoice!=Poll.SkinValue.MultipleChoice)	Poll.MultipleChoice.Set(fastCSharp.Poll.Query.MultipleChoice=Value.MultipleChoice);
	if(Value.Problem!=Poll.SkinValue.Problem)	Poll.Problem.Set(fastCSharp.Poll.Query.Problem=Value.Problem);
	if(Value.PrivateProblem!=Poll.SkinValue.PrivateProblem)
		{
		fastCSharp.Poll.Query.PrivateProblem=Value.PrivateProblem;
		if(Poll.PrivateProblem)	Poll.PrivateProblem.Set(Value.PrivateProblem);
		}
	if(Value.Question!=Poll.SkinValue.Question)	Poll.Question.Set(fastCSharp.Poll.Query.Question=Value.Question);
	if(Value.Message!=SkinValue.SkinValue.currentUser.MessageNewUserCount)	SkinValue.currentUser.MessageNewUserCount.Set(fastCSharp.Poll.Query.Message=Value.Message);
	this.LoadNotices();
	},
LoadNotices:function()
	{
	var SkinValue=fastCSharp.PageView.SkinValue,Poll=SkinValue.currentUser.EnterprisePoll,Count=SkinValue.SkinValue.currentUser.EnterprisePoll.Notice;
	if(Poll.SkinValue.Notices.length)	this.NoticeMenu.IsShow=1;
	else	{
		this.NoticeMenu.Hide();
		this.NoticeMenu.IsShow=0;
		}
	Poll.Notices.Set();
	fastCSharp.Poll.Query.NoticeIds=Poll.SkinValue.Notices.ToArray(function(Value){return Value.Id;});
	SkinValue.SkinValue.noticeHeader=Count?'('+Count+') ':'';
	fastCSharp.ChangeHeader();
	},
ReadNotice:function(NoticeId)
	{
	for(var SkinValue=fastCSharp.PageView.SkinValue,Poll=SkinValue.SkinValue.currentUser.EnterprisePoll,Values=Poll.Notices,Index=Values.length;--Index>=0;)
		{
		var Notice=Values[Index];
		if(Notice.Id==NoticeId)
			{
			this.ReadNoticeIds[NoticeId]=1;
			Poll.Notices.splice(Index,1);
			SkinValue.currentUser.EnterprisePoll.Notice.Add(-1);
			this.LoadNotices();
			LoadAjax.Post(fastCSharp.ThisFunction(this,this.OnReadNotice,[Notice]),'enterprise.notice.Read',{ids:[NoticeId]});
			return;
			}
		}
	},
OnReadNotice:function(Value,Notice)
	{
	if(Value.__AJAXRETURN__)
		{
		switch(Notice.Type)
			{
			case 'ExamFinally':	location.replace(new diantou.exam({Id:Notice.Remote.Exam.Id}).Path.Edit);	return;
			case 'Recharge':	location.replace(fastCSharp.PageView.SkinValue.SkinValue.currentUser.Path.EnterpriseAccount);	return;
			}
		}
	},
ReadNotices:function()
	{
	var SkinValue=fastCSharp.PageView.SkinValue.SkinValue,Notices=SkinValue.currentUser.EnterprisePoll.Notices,Count=fastCSharp.PageView.SkinValue.currentUser.EnterprisePoll.Notice;
	for(var Index=Notices.length,Ids=[];Index;)
		{
		var NoticeId=Notices[--Index].Id;
		this.ReadNoticeIds[NoticeId]=1;
		Ids.push(NoticeId);
		}
	SkinValue.currentUser.EnterprisePoll.Notices=[];
	Count.Add(-Ids.length);
	this.LoadNotices();
	if(Ids.length)	LoadAjax.Post(null,'enterprise.notice.Read',{ids:Ids});
	}
		};
fastCSharp.OnLoad(Header.Load,Header,1);